<?php

//Wish handling library

function show_link($wish) {
?>
<?=itemstats_parse("[item]" . $wish["item_id"] . "[/item]")?> <a href="item-view.php?id=<?=$wish["item_id"]?>">item</a><br/>
<?php
}

function show_pure($wish) {
?>
<?=itemstats_parse("[item]" . $wish["item_id"] . "[/item]")?>
<?php
}

function show_wish($wish, $src, $sys) {
  if($sys["system_tier"]==4) {
  show_link($wish);
     if($wish["wish_level"]==3) {
?>
<b>Max</b>
<?php
     }
     else {
?>
<a href="make-wish.php?id=<?=$wish["item_id"]?>&level=3&src=<?=$src?>">Max</a> 
<?php
     }

     if($wish["wish_level"]==2) {
?>
<b>Mod</b>
<?php
     }
     else {
?>
<a href="make-wish.php?id=<?=$wish["item_id"]?>&level=2&src=<?=$src?>">Mod</a> 
<?php
     }
?>
<?php

?>

<?php
     if($wish["wish_level"]==1) {
?>
<b>Min</b>
<?php
     }
     else {
?>
<a href="make-wish.php?id=<?=$wish["item_id"]?>&level=1&src=<?=$src?>">Min</a> 
<?php
    }
?>
<?php

?>
<?php
     if($wish["wish_level"]<=0) {
?>
<b>Non</b>
<?php
     }
     else {
?>
<a href="make-wish.php?id=<?=$wish["item_id"]?>&level=0&src=<?=$src?>">Non</a>
<?php
     }
?>
<br /><br />

<?php
   }
  //ENDS TIER 4 CODE, BELOW IS TIER 5+
  else {
  show_link($wish);
     if($wish["wish_level"]==4) {
?>
<b>Max</b>
<?php
     }
     else {
?>
<a href="make-wish.php?id=<?=$wish["item_id"]?>&level=4&src=<?=$src?>">Max</a> 
<?php
     }

     if($wish["wish_level"]==3) {
?>
<b>Mod</b>
<?php
     }
     else {
?>
<a href="make-wish.php?id=<?=$wish["item_id"]?>&level=3&src=<?=$src?>">Mod</a> 
<?php
     }
?>
<?php

?>

<?php
     if($wish["wish_level"]==2) {
?>
<b>Min</b>
<?php
     }
     else {
?>
<a href="make-wish.php?id=<?=$wish["item_id"]?>&level=2&src=<?=$src?>">Min</a> 
<?php
    }
?>
<?php

?>

<?php
     if($wish["wish_level"]==1) {
?>
<b>Micro</b>
<?php
     }
     else {
?>
<a href="make-wish.php?id=<?=$wish["item_id"]?>&level=1&src=<?=$src?>">Micro</a> 
<?php
    }
?>
<?php

?>


<?php
     if($wish["wish_level"]<=0) {
?>
<b>Non</b>
<?php
     }
     else {
?>
<a href="make-wish.php?id=<?=$wish["item_id"]?>&level=0&src=<?=$src?>">Non</a>
<?php
     }
?>
<br /><br />

<?php
  }
}

function show_item($item, $character, $db, $src, $sys=0) {
  $sql = "select * from wm_wishes where wish_item = '" . $item["item_id"] . "' and wish_character='" . $character["character_id"] . "'";
  $result = $db->query($sql);
  $wish = $db->fetch_assoc($result);
  if($wish["wish_level"]>0) {
    $sql = "select * from wm_wishes left join wm_items on wm_wishes.wish_item = wm_items.item_id where wish_character = '" . $character["character_id"] . "' and wish_item='" . $item["item_id"] . "'";    
    $result = $db->query($sql);
    $wish = $db->fetch_assoc($result);
    show_wish($wish, $src, $sys);
  }
  else {
    show_wish($item, $src, $sys);
  }
}

?>
